<?php
   class Links extends MY_Controller{
	   public function __construct(){
		   parent::__construct();
		   $this->load->helper("url");
		   $this->load->model("model_home");
	   }
	   public function index(){	
		   $data['title'] = "Links Exchange";
		   $data['config']    = $this->config();
		   $data['listall']   = $this->model_home->getlink();
		   //$this->debug($data['listall']);
		   $this->load->view("links/layout",$data);
	   }
	   public function listall(){
		   $segment = $this->uri->segment(1); 
		   $id = $this->uri->segment(2);
		   //$id = array_pop(explode('-', $segment));
		   $config['base_url'] = base_url().$segment."/".$id."";
		   $config['total_rows'] = $this->model_home->count_all_link($id);
		   $config['per_page'] = 15;
		   $config['uri_segment'] = 3;
		   $config['cur_tag_open'] = '<span class="active">';
		   $config['cur_tag_close'] = '</span>';
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);
		   $data['config']    = $this->config();
		   $start = (int)$this->uri->segment(3);
		   $data['listall']  = $this->model_home->list_all_link($id,$config['per_page'],$start);
 		   //$this->debug($data['listall']);
		   $data['title'] = "Links Exchange";
		   //$this->debug($data['listall']);
		   $this->load->view("links/view/layout",$data);
	   }
	   public function view(){	
	   	   $id = $this->uri->segment(1);
		   $id = array_pop(explode('-', $id));
		   $data['config']    = $this->config();
		   $data['links']   = $this->model_home->getvallink($id);
		   if($data['links'] == NULL){
			   redirect(base_url());
		   }
		   $data['title'] = $data['links']['content_title'];
		   //$this->debug($data['listall']);
		   $this->load->view("links/view/layout",$data);
	   }
   }